package com.yqg.protection.listenern;

import cn.hutool.core.bean.BeanUtil;
import com.alibaba.excel.context.AnalysisContext;
import com.alibaba.excel.event.AnalysisEventListener;
import com.yqg.protection.controller.dto.ImportRecordNoticeDto;
import com.yqg.protection.entity.RecordNotice;
import com.yqg.protection.mapper.RecordNoticeMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

/**
 * projectName:xf-service1
 * author:zxf
 * time:2024/10/15 15:03
 * description:
 */
@Component
public class RecordNoticeListener extends AnalysisEventListener<ImportRecordNoticeDto> {

    @Autowired
    private RecordNoticeMapper recordNoticeMapper;

    @Override
    public void invoke(ImportRecordNoticeDto importRecordNoticeDto, AnalysisContext analysisContext) {
        RecordNotice recordNotice = new RecordNotice();
        BeanUtil.copyProperties(importRecordNoticeDto, recordNotice, true);
        recordNoticeMapper.insert(recordNotice);
    }

    @Override
    public void doAfterAllAnalysed(AnalysisContext analysisContext) {

    }
}
